var NowUsers;
function setCookie(cname,cvalue,exdays){
	var d = new Date();
	d.setTime(d.getTime()+(exdays*24*60*60*1000));
	var expires = "expires="+d.toGMTString();
	document.cookie = cname+"="+cvalue+"; "+expires;
}
function getCookie(cname){
	var name = cname + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i<ca.length; i++) {
		var c = ca[i].trim();
		if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
	}
	return "";
}
function signin(){
    var UserName=prompt("用户名","");
	while(UserName==""){
		prompt("用户名不能为空，请重新输入","");
	}
    while(getCookie(UserName)!=""){
		prompt("用户名已被注册，请重新输入","");
		while(UserName==""){
			prompt("用户名不能为空，请重新输入","");
		}
	}
	var Password=prompt("密码，注意，暂未开通忘记密码功能，请选择一个不容易忘记的密码","");
	setCookie(UserName,Password,30);
	alert("注册成功，注意：如果连续30天未登录，会自动注销账号（清理cookies也会导致账号被清理）");
}
function signout(){
	var UserName=prompt("用户名","");
	while(UserName==""){
		prompt("用户名不能为空，请重新输入","");
	}
	while (getCookie(UserName)=="") {
		UserName=prompt("用户名不存在，可能原因：\n1.没注册，请点击“注册”后登录\n2.账号已被注销 连续30天未登录会自动注销账号，清理cookies也会导致账号被清理\n3.用户名输入错误\n请重新输入用户名或点击注册","");
		while(UserName==""){
			prompt("用户名不能为空，请重新输入","");
		}
	}
	var Password1=getCookie(UserName);
	var Password=prompt("密码","");
	while (Password!=Password1) {
		Password=prompt("密码错误，请重新输入。如果忘记密码，请重新注册","");
	}
	setCookie(UserName,Password,30);
	alert("登录成功！");
}